var express = require('express');
var query=require('../conn/conn');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});
router.get('/getItems', async (req, res, next)=>{
    let results =await query(`SELECT * FROM product WHERE 1`)
    res.send(results)
});
router.get('/getItem', async (req, res, next)=>{
    console.log(req.query);
    let results =await query(`SELECT * FROM product WHERE id=${req.query.product_id}`)
    res.send(results)
});
router.get('/shop_list', async(req, res, next) => {
    let idList = req.query['idList'];
    console.log(idList);
    let result = await query(`select * from product where id in (${idList})`);
    console.log(result);
    res.send(result);
});



module.exports = router;

